#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ull unsigned ll
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define pii pair<int,int>
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(),v.end()
#define lbt(i) (i&-i)
using namespace std;
const int N = 1e5+5, mod = 998244353, M = 1e6+5;
// be careful with multiple cases
struct cars {
    ll d,v,a;
    pii qj;
} c[N];
int p[N];
vector<pii> vc;
void solve() {
    vc.clear();
    // first check the init.
    ll n,m,l,vmx;
    cin>>n>>m>>l>>vmx;
    auto mcl = [&](ll a,ll b) -> ll {
        return (a+b-1)/b;
    };
    auto cal = [&](ll d,ll v,ll a) -> pii {
        if(a==0) {
            if(v>vmx) return {d,l};
            return {-1,-1};
        } if(a>0) {
            if(v>vmx) return {d,l};
            // v <= vmx, a > 0
            ll pos=(vmx*vmx-v*v)/(2ll*a);
            if(d+pos+1>l) return {-1,-1};
            return {d+pos+1,l}; 
        }
        if(v<=vmx) return {-1,-1};
        // v > vmx, a < 0
        ll pos=mcl((v*v-vmx*vmx),(-2ll*a));
        return {d,min(l,d+pos-1)};
    };
    rep(i,1,n) {
        cin>>c[i].d>>c[i].v>>c[i].a;
        c[i].qj=cal(c[i].d,c[i].v,c[i].a);
        // cout<<c[i].qj.x<<' '<<c[i].qj.y<<'\n';
    }
    rep(i,1,m) cin>>p[i];
    auto fmin = [&](int id) -> int {
        auto tt=lower_bound(p+1,p+m+1,id)-p;
        return tt;
    };
    auto fmax = [&](int id) -> int {
        auto tt=upper_bound(p+1,p+m+1,id)-p-1;
        return tt;
    };
    rep(i,1,n) {
        int st=c[i].qj.x,ed=c[i].qj.y;
        if(st==-1) continue;
        int s=fmin(st),t=fmax(ed);
        if(s>t) continue;
        vc.pb({s,t});
    } cout<<vc.size()<<' ';
    int res=0,now=0;
    sort(all(vc),[&](pii a,pii b){return a.y<b.y;});
    for(auto c:vc) {
        int st=c.x,ed=c.y;
        if(now<st) res++,now=ed;
    } cout<<m-res<<'\n';
}
signed main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int T; cin>>T;
    while(T--) solve();
    return 0;
}
/*
!!! read the problem carefully at least twice !!!
!! keep a positive attitude, confident and calm, ur attitude counts!
1. think carefully before u start
2. when debugging, don't output much, firstly read the whole program again
3. balance the loss and get, this is important
4. do all the easy bruteforce first
5. remember to duipai, check the correctness and time.
6. long long, devide zero, array out of range!

at last:
checker the version of the program and put it under the correct folder
check extra output or wrong output of samples 
*/